home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
Tools
/
freeWAIS-sf-1.1
/
ctype
/
mkctype.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-05
|
5KB
|
182 lines
/* -*- Mode: C -*-
* mkctype.c --
* ITIID : $ITI$ $Header $__Header$
* Author : Ulrich Pfeifer
* Created On : Wed Mar 23 09:45:04 1994
* Last Modified By: Ulrich Pfeifer
* Last Modified On: Tue Dec 6 17:25:28 1994
* Update Count : 45
* Status : Unknown, Use with caution!
*/
/* HISTORY
* 22-Jul-1994 Ulrich Pfeifer
* Last Modified: Fri Jul 22 14:33:16 1994 #39 (Ulrich Pfeifer)
* Moved str*cmp* stuff to ctype.tmpl
*/
#include "../ir/cdialect.h"
#include <ctype.h>
#include <stdio.h>
#ifndef LCHARS
#define LCHARS "Σ÷ⁿ▀"
#endif
#ifndef UCHARS
#define UCHARS "─╓▄▀"
#endif
#ifndef CTYPEVAR
unsigned char _ctype_[]= {
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x28,0x28,0x28,0x28,0x28,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x88,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,
0x10,0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#ifdef _U
#undef _U
#endif
#define _U 0x01
#ifdef _L
#undef _L
#endif
#define _L 0x02
#ifdef _N
#undef _N
#endif
#define _N 0x04
#ifdef _S
#undef _S
#endif
#define _S 0x08
#ifdef _P
#undef _P
#endif
#define _P 0x10
#ifdef _C
#undef _C
#endif
#define _C 0x20
#ifdef _X
#undef _X
#endif
#define _X 0x40
#ifdef _B
#undef _B
#endif
#define _B 0x80
#define CTYPEVAR _ctype_
#endif /* CTYPEVAR */
unsigned char ctype[256];
unsigned char tToUP[256]; /* char of the ones converted toupper by our INTL mcaro */
unsigned char tToLOW[256]; /* char of the ones converted tolower by our INTL mcaro */
/* This is a copy from the funtion in ../ir/cutil.c :( */
#ifdef NEED_MYBCOPY
void
mybcopy(b1, b2, length)
char *b1, *b2;
int length;
{
int i;
if (b1 > b2) {
for (i=0;i<length;i++) {
b2[i] = b1[i];
}
} else {
for (i=length-1;i>=0;i--) {
b2[i] = b1[i];
}
}
}
#endif /* NEED_MYBCOPY */
main()
{
int i,j;
unsigned char *s;
/* extern void bcopy(); */
bcopy(CTYPEVAR,ctype,256*sizeof(char));
printf("unsigned char _lchars_[] = \"%s\";\n", LCHARS);
printf("unsigned char _uchars_[] = \"%s\";\n", UCHARS);
for(s=(unsigned char*)LCHARS;*s;s++) {
/* why do you shift all by one in ctype ? MN */
ctype[*s+1] |= _L;
ctype[*s+1] &= ~(_S|_N|_P);
fprintf(stderr, "_ctype[%d]=%d\n", *s+1,ctype[*s+1]);
}
for(s=(unsigned char*)UCHARS;*s;s++) {
ctype[*s+1] |= _U;
ctype[*s+1] &= ~(_S|_N|_P);
fprintf(stderr, "_ctype[%d]=%d\n", *s+1,ctype[*s+1]);
}
printf("unsigned\n#ifdef STDC_HEADERS\nconst\n#endif\nchar _fw_ctype_[]= {\n");
for (i=0;i<16;i++) {
for (j=0;j<16;j++) {
printf("0x%02x,", ctype[i*16+j]);
}
printf("\n");
}
printf("};\n");
/* MN addition */
/* identity transform ... I know too many ops - but simple and done only once */
for( i=0; i<256; i++)
tToUP[i] = tToLOW[i] = (unsigned char)i;
for( i=0; i <= ('Z'-'A'); i++){ /* 7bit ASCII toupper/lower lookup table */
tToLOW[(int)(i+'A')] = i + 'a';
tToUP[(int)(i+'a')] = i + 'A';
}
{unsigned char *pLowChars, *pUpChars;
for( pLowChars = (unsigned char*)LCHARS, pUpChars = (unsigned char*)UCHARS;
*pLowChars && *pUpChars; pLowChars++, pUpChars++ ){
tToLOW[ *pUpChars ] = *pLowChars; /* remember the next tolower conversion item */
tToUP[ *pLowChars ] = *pUpChars; /* remember the next toupper conversion item */
}
}
printf("\n#ifndef STDC_HEADERS\n");
printf("#define INTL_CTYPE_MODULE \n");
printf("unsigned char tToUP[]= {\n");
for (i=0;i<16;i++) {
for (j=0;j<16;j++) {
printf("0x%02x,", tToUP[i*16+j]);
}
printf("\n");
}
printf("};\n");
printf("unsigned char tToLOW[]= {\n");
for (i=0;i<16;i++) {
for (j=0;j<16;j++) {
printf("0x%02x,", tToLOW[i*16+j]);
}
printf("\n");
}
printf("};\n");
printf("#endif\n");
/* MN */
exit(0);
}